#include<iostream>
using namespace std;
#include<vector>

int minPathSum(vector<vector<int>>& grid) {
	int length1 = grid.size(), length2 = grid[0].size();
	vector<int> temp(length2 , 0);
	vector<vector<int>> dp(length1 , temp);

	for (int i = 0; i <= length1; i++)
	{
		for (int j = 0; j <= length2; j++)
		{
			if (i == 0&&j==0)
			{
				dp[i][j] = grid[i][j];
			}
			else if (i == 0)
			{
				dp[i][j] = dp[i][j - 1] + grid[i][j];
			}
			else if (j == 0)
			{
				dp[i][j] = dp[i-1][j] + grid[i][j];
			}
			else
			{
				dp[i][j] = min(dp[i - 1][j], dp[i][j-1]) + grid[i][j];
			}
		}
	}
	return dp[length1-1][length2-1];
}

int main()
{
	return 0;
}